package com.zheng.study.base.bean.search.result;

import com.zheng.study.base.bean.search.Search;
import org.springframework.util.Assert;

import java.util.List;

/**
 * 查询 - 结果 - SearchResultList
 * ============================================================================
 * author : fallenpanda
 * createDate:  2018/6/12 。
 * ============================================================================
 */
public class SearchResultList extends SearchResult {

	protected final List list;

	public SearchResultList(Search search, List list) {
		super(search);
		this.list = list;
	}

	public List getList() {
		return list;
	}

	public static SearchResultList list(Search search, List list){
		return newBuilder().setSearch(search).setList(list).build();
	}

	public static Builder newBuilder(){
		return new Builder();
	}

	public static class Builder extends SearchResult.Builder<SearchResult, Builder>{

		protected List list;

		public Builder setList(List list) {
			this.list = list;
			return this;
		}

		@Override
		protected Builder getThis() {
			return this;
		}

		@Override
		public SearchResultList build() {
			Assert.notNull(search, "search 不能为空");
			Assert.notNull(list, "list 不能为空");
			return new SearchResultList(search, list);
		}
	}

}
